package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.*;

/**
 * @author 杨兴健
 * @Date 2020/7/9 9:49
 */
@Getter
@Setter
@ToString
public class Employee {
    /**
     * 员工id
     */
    private Long id;
    /**
     * 员工名称
     */
    private String name;
    /**
     * 员工邮箱
     */
    private String email;
    /**
     * 员工年龄
     */
    private Integer age;
    /**
     * 入职时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date hireDate;
    /**
     * 员工是否是管理员
     */
    private boolean admin;

    /**
     * 用户状态
     */
    private boolean status = true;

    /**
     * 员工密码
     */
    private String password;
    /**
     * 员工部门
     */
    private Department dept = new Department();
    /**
     * 员工角色
     */
    private List<Role> roles = new ArrayList<>();

    /**
     * 获取员工id
     *
     * @return
     */
    public Long getDeptId() {
        return dept.getId();
    }

    /**
     * 返回json
     *
     * @return
     */
    private String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("email", email);
        map.put("age", age);
        map.put("admin", admin);
        map.put("dept", dept);
        map.put("roles", roles);
        return JSON.toJSONString(map);
    }


}
